package com.zyb.patient.widget;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.zyb.patient.R;
import com.zyb.patient.view.DateSelectorWheelView;

public class TimePickerDialog extends DialogFragment implements View.OnClickListener {

    TextView mTimePickerTitle = null;

    DateSelectorWheelView mDatePicker = null;

    Button mOkButton = null;

    TextView mCancelButton = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        setStyle(STYLE_NO_TITLE, R.style.time_picker_dialog);
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.fragment_time_picker, null);
        mTimePickerTitle = (TextView) view.findViewById(R.id.time_picker_title);
        mDatePicker = (DateSelectorWheelView) view.findViewById(R.id.date_picker);
        mOkButton = (Button) view.findViewById(R.id.ok);
        mCancelButton = (Button) view.findViewById(R.id.cancel);
        initView();
        return view;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.ok:
            mDatePicker.getSelectedDate();
            dismiss();
            break;

        case R.id.cancel:
            dismiss();
            break;
        }

    }

    private void initView() {
        mOkButton.setOnClickListener(this);
        mCancelButton.setOnClickListener(this);
    }

    public void setDatePickerTitle(int resId) {
        mTimePickerTitle.setText(resId);
    }

}
